﻿// The Icon widget creates an element where the image and its size are set by two CSS classes
define([
    'Wjs/ui/elements/View'
],
function () {
    'use strict';

    return Wjs.defineOnce({

        type: 'Icon',

        internal: {

            base: Wjs.getType('View'),

            initialize: function () {

                this

                    .setTag('img')

                    .setIconClass('wjs-icon-default')

                    .setSizeClass('wjs-icon-size-small');
            }
        },

        setIconClass: function (iconClass) {

            if (!this.iconClass) {

                this.addClass(iconClass);
            }
            else {

                this.replaceClass(this.iconClass, iconClass);
            }

            this.iconClass = iconClass;

            return this;
        },

        setSizeClass: function (iconSize) {

            if (!this.iconSize) {

                this.addClass(iconSize);
            }
            else {

                this.replaceClass(this.iconSize, iconSize);
            }

            this.iconSize = iconSize;

            return this;
        }
    });

});